/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package cpasl;

import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Pos;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.RadioButton;
import javafx.scene.control.ToggleGroup;
import javafx.scene.layout.GridPane;

/**
 *
 * @author seanm_000
 */
public class AslStartGridPane extends GridPane {
    
    public AslStartGridPane() {
        setAlignment(Pos.CENTER);
        setHgap(15);
        setVgap(15);
        
        Label aslStartLabel = new Label("At what age did you begin learning ASL?");
        final ToggleGroup aslStartGroup = new ToggleGroup();
        RadioButton zeroButton = new RadioButton("0 – 5");
        zeroButton.setUserData("A");
        zeroButton.setToggleGroup(aslStartGroup);
        zeroButton.setSelected(true);
        RadioButton sixButton = new RadioButton("6 – 10");
        sixButton.setUserData("B");
        sixButton.setToggleGroup(aslStartGroup);
        RadioButton elevenButton = new RadioButton("11 – 15");
        elevenButton.setUserData("C");
        elevenButton.setToggleGroup(aslStartGroup);
        RadioButton sixteenButton = new RadioButton("16 – 20");
        sixteenButton.setUserData("D");
        sixteenButton.setToggleGroup(aslStartGroup);
        RadioButton twentyOneButton = new RadioButton("21 – 25");
        twentyOneButton.setUserData("E");
        twentyOneButton.setToggleGroup(aslStartGroup);
        RadioButton twentySixButton = new RadioButton("26 +");
        twentySixButton.setUserData("F");
        twentySixButton.setToggleGroup(aslStartGroup);
        
        Button nextButton = new Button();
        nextButton.setText("Next");
        nextButton.setId("next-button");
        nextButton.setOnAction(new EventHandler<ActionEvent>() {

            @Override
            public void handle(ActionEvent event) {
                String userData = (String) ((RadioButton) aslStartGroup.getSelectedToggle()).getUserData();
                CpaslManager.getInstance().setStartAgeAsl(userData);
                CpaslManager.getInstance().switchToDisplay(Groups.ASL_FREQUENCY, 0);
            }
        });
        
        add(aslStartLabel, 0, 0);
        add(zeroButton, 0, 1);
        add(sixButton, 0, 2);
        add(elevenButton, 0, 3);
        add(sixteenButton, 0, 4);
        add(twentyOneButton, 0, 5);
        add(twentySixButton, 0, 6);
        add(nextButton, 0, 7);
    }
    
}
